#!/usr/bin/env python
#-*- coding:utf-8 -*-

from sqlalchemy import Column, Integer, Text, Sequence, ForeignKey
from sqlalchemy.orm import relationship, backref
from models.base import Base


class Article(Base):
    __tablename__ = "articles"
    id = Column(Integer, Sequence('article_id_seq'), primary_key=True)
    markdown_content = Column(Text, nullable=False)
    html_content = Column(Text, nullable=False)
    user_id = Column(Integer, ForeignKey('users.id'))

    user = relationship("User", backref=backref('articles', order_by=id))

    def __repr__(self):
        return "<Article(%d)>" % self.id
